package com.sc.admin.base.mapper;

import com.sc.core.make.vo.TableColumn;
import com.sc.core.make.vo.TableInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SystemMapper {

    @Select("SELECT table_name, table_comment FROM INFORMATION_SCHEMA.TABLES WHERE table_name = #{tableName} AND table_schema = (SELECT DATABASE())")
    TableInfo getTableInfo(String tableName);

    @Select("SELECT column_name, column_comment, column_type, character_maximum_length as column_length, column_default FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = #{tableName} AND table_schema = (SELECT DATABASE()) ORDER BY ORDINAL_POSITION")
    List<TableColumn> getTableColumn(String tableName);

    @Select("SELECT table_name, table_comment FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = (SELECT DATABASE())")
    List<TableInfo> getTableList();
}
